new Vue({
  el: '#app',
  data: {
    active: 2,
    loading: true,
    amount: '',
    value: '',
    errorInfo: '',
    showKeyboard: false,
  },
  mounted () {
    this.main() 
  },
  methods: {
    main() {
      // $http.get('/api/user/getUserInfo').then(res => {
      //   this.user = res.data.data
      //   return $http.get('/api/index/systemdeta')
      // }).then( (res) => {
      //   this.usdturl = res.data.data.usdturl
      // })
    },
    onClickLeft: function () {
      history.go(-1)
    },
    onInput(key) {
      this.value = (this.value + key).slice(0, 6);
      if (this.value.length !== 6) {
        return
      } 

      $http.get('/api/otc/createsellOrder').then(res => {
        if (res.data.code != 1) { 
          this.value = ''
          return this.errorInfo = res.data.msg
         }

        this.$toast.success({
          message: res.data.msg,
          onClose: function () { history.go(-1) }
        })
        
      })
    },
    onDelete() {
      this.value = this.value.slice(0, this.value.length - 1);
    },
    onCreateOrder() {
      if(!this.amount) {
        this.$toast.fail('请填写USDT数量')
        return;
      }

      this.value = ''
      this.errorInfo = ''
      this.showKeyboard = true
    }
  }
})